# -*- coding: utf-8 -*-
__author__ = 'JK'
__date__ = '2019/4/11 22:40'

import os, yaml
from django.http import JsonResponse
from LitterProject import settings
from utils import responses

def init_app_data():
    data_file = os.path.join(settings.BASE_DIR, 'app.yaml')
    with open(data_file, 'r', encoding='utf-8') as f:
        apps = yaml.load(f)
        return apps

def get_menu(request):
    globals_app_data = init_app_data()
    published_app_data = globals_app_data.get('published')
    response_data = responses.wrap_json_response(data=published_app_data,
                                                 code=responses.ReturnCode.SUCCESS)
    return JsonResponse(data=response_data, safe=False, json_dumps_params={'ensure_ascii':False})
